home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Very Best of Atari Inside
/
The Very Best of Atari Inside 1.iso
/
mint
/
mntlb20
/
lib
/
strchr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-26
|
670b
|
34 lines
/* from Henry Spencer's stringlib */
/* modified by ERS */
#include <string.h>
/*
* strchr - find first occurrence of a character in a string
*/
#ifdef __GNUC__
__asm__(".text; .even; .globl _index; _index:"); /* dept of dirty tricks */
#else
char *
index(s, charwanted)
const char *s;
char charwanted;
{
return strchr(s, charwanted);
}
#endif
char * /* found char, or NULL if none */
strchr(s, charwanted)
const char *s;
register char charwanted;
{
register char c;
/*
* The odd placement of the two tests is so NUL is findable.
*/
while ((c = *s++) != charwanted)
if (c == 0) return NULL;
return((char *)--s);
}